//
//  RecommendBigMenuView.swift
//  MyTest
//
//  Created by guanzhongwang on 2021/5/18.
//

import UIKit

class RecommendBigMenuView: UIView {
    private var menuTap:(()->Void)!
    var title:String!
    init(title:String,message:String,icon:String,bgColor:UIColor,tap:@escaping ()->Void) {
        super.init(frame: .zero)
        self.menuTap = tap
        self.title = title
        setRadiusAndDirection(radius: 6)
        self.backgroundColor = bgColor
        let titleLabel = UILabel()
        titleLabel.text = title
        titleLabel.textColor = B000_COLOR
        titleLabel.font = getLabelFont(15, blod: true)
        addSubview(titleLabel)
        let messageLabel = UILabel()
        messageLabel.textColor = B999_TITLE_COLOR
        messageLabel.text = message
        messageLabel.font = Font_Size_13
        addSubview(messageLabel)
        let iconImage = UIImageView(image: UIImage(named: icon))
        addSubview(iconImage)
        let tagImage = UIImageView(image: UIImage(named: "add"))
        addSubview(tagImage)
        let margin = 15
        iconImage.snp.makeConstraints({
            $0.left.top.equalTo(margin)
            $0.width.height.equalTo(margin)
        })
        titleLabel.snp.makeConstraints({
            $0.left.equalTo(iconImage.snp.right).offset(5)
            $0.centerY.equalTo(iconImage)
        })
        
        tagImage.snp.makeConstraints({
            $0.centerY.equalTo(iconImage)
            $0.right.equalToSuperview().inset(5)
            $0.width.height.equalTo(20)
        })
        
        messageLabel.snp.makeConstraints({
            $0.left.equalTo(margin)
            $0.top.equalTo(iconImage.snp.bottom).offset(10)
            $0.bottom.equalToSuperview().inset(margin)
        })
        addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(buttonTap)))
    }
    @objc func buttonTap(){
        self.menuTap()
    }
    required init?(coder: NSCoder) {
        fatalError()
    }

}
